package com.xhh.nphm.web.controller.system;

import com.xhh.nphm.common.core.controller.BaseController;
import com.xhh.nphm.common.core.domain.AjaxResult;
import com.xhh.nphm.common.core.domain.QueryConditionVo;
import com.xhh.nphm.common.core.domain.entity.SysUser;
import com.xhh.nphm.common.core.page.PageDomain;
import com.xhh.nphm.common.core.page.TableDataInfo;
import com.xhh.nphm.common.core.page.TableSupport;
import com.xhh.nphm.common.utils.DateUtils;
import com.xhh.nphm.common.utils.MapDataUtil;
import com.xhh.nphm.common.utils.StringUtils;
import com.xhh.nphm.common.utils.poi.ExcelUtil;
import com.xhh.nphm.system.domain.*;
import com.xhh.nphm.system.mapper.CommonDao;
import com.xhh.nphm.system.mapper.DataExportDao;
import com.xhh.nphm.system.service.IWfSendBackService;
import com.xhh.nphm.system.service.MwfSendBackService;
import com.xhh.nphm.web.controller.common.CommonController;
import lombok.val;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("")
public class MWFDeptPgCtrl extends BaseController {

    private String prefix = "system";

    @Autowired
    private CommonDao commonDao;

    @Autowired
    private DataExportDao dataExportDao;

    @Autowired
    private IWfSendBackService wfSendBackService;

    @Autowired
    private MwfSendBackService mwfSendBackService;

    @Autowired
    private CommonController commonController;

    /**
     * 本单位信件工单列表页
     * @return
     */
    @RequestMapping("system/lookup/mailWFDept")
    public ModelAndView mailWFDeptPage() {
        return new ModelAndView(prefix + "/lookup/mailWFDept");
    }
    /**
     * 信件操作记录列表页
     * @return
     */
    @RequestMapping("system/lookup/mailLogList")
    public ModelAndView mailLogListPage() {
        return new ModelAndView(prefix + "/lookup/mailLogList");
    }
    /**
     * 电话操作记录列表页
     * @return
     */
    @RequestMapping("system/lookup/telLogList")
    public ModelAndView telLogListPage() {
        return new ModelAndView(prefix + "/lookup/telLogList");
    }
    /**
     * 本单位电话工单列表页
     * @return
     */
    @RequestMapping("system/lookup/telWFDept")
    public ModelAndView telWFDeptPage() {
        return new ModelAndView(prefix + "/lookup/telWFDept");
    }
    /**
     * 下级单位电话工单列表页
     * @return
     */
    @RequestMapping("system/lookup/subDeptTelWF")
    public ModelAndView subDeptTelWFPage() {
        return new ModelAndView(prefix + "/lookup/subDeptTelWF");
    }
    /**
     * 下级单位信件工单列表页
     * @return
     */
    @RequestMapping("system/lookup/subDeptMailWF")
    public ModelAndView subDeptMailWFPage() {
        return new ModelAndView(prefix + "/lookup/subDeptMailWF");
    }
    /**
     * 本单位信件工单数据
     * @return
     */
    @PostMapping("system/lookup/mailWFDeptListJson")
    public Object mailWFDeptListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("pkid");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<Map> mailWFDeptList = commonDao.mailWFDeptListJson(MapDataUtil.multiTypeParamListToMap(queryConditionVo, sbDeptId));
        for (Map<String,Object> map : mailWFDeptList) {
            Map<String, Object> judgeC = commonDao.findMailJudgeByWfId(map.get("WfId").toString());
            if (judgeC != null){
                map.putAll(judgeC);
            }
        }
        return getDataTable(mailWFDeptList);
    }

    /**
     * 信件操作记录数据
     * @return
     */
    @PostMapping("system/lookup/mailLogListJson")
    public Object mailLogListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("myPkVal");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(queryConditionVo.getEndTime()==null||"".equals(queryConditionVo.getEndTime())){
            Date date = new Date();
            String format = dateFormat.format(date);
            queryConditionVo.setEndTime(format);
        }
        if (queryConditionVo.getBeginTime()==null||"".equals(queryConditionVo.getBeginTime())){
            try {
                Date date = dateFormat.parse(queryConditionVo.getEndTime());
                Calendar calendar = Calendar.getInstance(); //得到日历
                calendar.setTime(date);//把当前时间赋给日历
                calendar.add(calendar.MONTH, -1); //设置为前1月，可根据需求进行修改
                date = calendar.getTime();
                queryConditionVo.setBeginTime(dateFormat.format(date));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        List<Map> list = commonDao.mailLogList(getSysUser().getDeptId().toString(),queryConditionVo);
        TableDataInfo dataTable = getDataTable(list);
        return dataTable;
    }

    /**
     * 下级单位信件工单数据
     * @return
     */
    @PostMapping("system/lookup/subDeptMailWFListJson")
    public Object subDeptMailWFListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("pkid");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        return getDataTable(commonDao.subDeptMailWFList(sDeptId,queryConditionVo));
    }

    /**
     * 本单位电话工单数据
     * @return
     */
    @PostMapping("system/lookup/telWFDeptListJson")
    public Object telWFDeptListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("pkid");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<Map> telWFDeptList = commonDao.telWFDeptListJson(MapDataUtil.multiTypeParamListToMap(queryConditionVo, sbDeptId));
        for (Map<String,Object> map : telWFDeptList) {
            Map<String, Object> judgeC = commonDao.findTelJudgeByWfId(map.get("WfId").toString());
            if(judgeC != null){
                map.putAll(judgeC);
            }
        }
        return getDataTable(telWFDeptList);
    }

    /**
     * 电话操作记录列表数据
     * @return
     */
    @PostMapping("system/lookup/telLogListJson")
    public Object telLogListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("myPkVal");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(queryConditionVo.getEndTime()==null||"".equals(queryConditionVo.getEndTime())){
            Date date = new Date();
            String format = dateFormat.format(date);
            queryConditionVo.setEndTime(format);
        }
        if (queryConditionVo.getBeginTime()==null||"".equals(queryConditionVo.getBeginTime())){
            try {
                Date date = dateFormat.parse(queryConditionVo.getEndTime());
                Calendar calendar = Calendar.getInstance(); //得到日历
                calendar.setTime(date);//把当前时间赋给日历
                calendar.add(calendar.MONTH, -1); //设置为前1月，可根据需求进行修改
                date = calendar.getTime();
                queryConditionVo.setBeginTime(dateFormat.format(date));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        List<Map> list = commonDao.telLogList(getSysUser().getDeptId().toString(),queryConditionVo);
        return getDataTable(list);
    }

    /**
     * @Description: 下级单位电话工单数据
     * 2023/2/6
     * @Param: [queryConditionVo]
     * @return: java.lang.Object
     */
    // TODO
    @PostMapping("system/lookup/subDeptTelWFListJson")
    public Object subDeptTelWFListJson(QueryConditionVo queryConditionVo) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if(StringUtils.isEmpty(pageDomain.getOrderByColumn())) {
            pageDomain.setOrderByColumn("pkid");
            pageDomain.setIsAsc("desc");
        }
        startPage(pageDomain);
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        return getDataTable(commonDao.subDeptTelWFList(sDeptId,queryConditionVo));
    }

    /**
     * 本单位电话工单数据导出
     */
    @PostMapping("system/lookup/telWFDept/export")
    @ResponseBody
    public AjaxResult telExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<TelExcel> telWFDeptList = dataExportDao.telWFDeptListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sbDeptId));
        for (TelExcel telExcel : telWFDeptList) {
            commonController.hidetTel2(user,telExcel);
        }
        ExcelUtil<TelExcel> util = new ExcelUtil<>(TelExcel.class);
        return util.exportExcel(telWFDeptList, "本单位电话工单数据");
    }

    /**
     * 本单位电话工单不满意件数据导出
     */
    @PostMapping("system/lookup/UnsatisfyTelWF/export")
    @ResponseBody
    public AjaxResult UnsatisfyTelExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        Map<String, Object> param = MapDataUtil.multiTypeParamListToMap(queryConditionVo, sbDeptId);
        if(dataExportDao.telWFDissatisfyListTotal(param) > 0){
            ExcelUtil<TelExcel> util = new ExcelUtil<>(TelExcel.class);
            List<TelExcel> telWFDissatisfyList = dataExportDao.telWFDissatisfyListExport(param);
            for (TelExcel telExcel : telWFDissatisfyList) {
                commonController.hidetTel2(user,telExcel);
            }
            return util.exportExcel(telWFDissatisfyList, "本单位电话工单不满意数据");
        } else {
            return new AjaxResult(AjaxResult.Type.ERROR,"本单位暂无不满意电话工单！");
        }
    }

    /**
     * 下级单位电话工单数据导出
     */
    @PostMapping("system/lookup/subDeptTWFExport/export")
    @ResponseBody
    public AjaxResult subDeptTWFExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        List<TelExcel> subDeptTelWFList = dataExportDao.subDeptTelWFListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sDeptId));
        for (TelExcel telExcel : subDeptTelWFList) {
            commonController.hidetTel2(user,telExcel);
        }
        ExcelUtil<TelExcel> util = new ExcelUtil<>(TelExcel.class);
        return util.exportExcel(subDeptTelWFList, "下级单位电话工单数据");
    }
    /**
     * 下级单位电话工单数据导出(下拉选择时间导出)
     */
    @PostMapping("system/lookup/subDeptTWFExport/exportSelect")
    @ResponseBody
    public AjaxResult subDeptTWFExportSelect(QueryConditionVo queryConditionVo,int days) {
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        String endTime= DateUtils.getDate();
        String startTime=null;
        if(days<0){
            if (days==-1){
                try {
                    Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(endTime);
                    Date date = firstDayOfMonth(parse);
                    startTime= DateUtils.dateTime(date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        }else {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(new Date());
            calendar.add(Calendar.DATE, -days);
            startTime = DateUtils.dateTime(calendar.getTime());
        }

        queryConditionVo.setBeginTime(startTime);
        queryConditionVo.setEndTime(endTime);
        List<TelExcel> subDeptTelWFList = dataExportDao.subDeptTelWFListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sDeptId));
        for (TelExcel telExcel : subDeptTelWFList) {
            commonController.hidetTel2(user,telExcel);
        }
        ExcelUtil<TelExcel> util = new ExcelUtil<>(TelExcel.class);
        return util.exportExcel(subDeptTelWFList, "下级单位电话工单数据");
    }

    public Date firstDayOfMonth(Date date) {
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
        cal.set(Calendar.DAY_OF_MONTH, last);
        Date time = cal.getTime();
        return time;
    }
    public Date lastDayOfMonth(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.roll(Calendar.DAY_OF_MONTH, -1);
        return cal.getTime();
    }

    /**
     * 本单位信件工单数据导出
     */
    @PostMapping("system/lookup/mailWFDept/export")
    @ResponseBody
    public AjaxResult mailExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<MailExcel> mailWFDeptList = dataExportDao.mailWFDeptListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sbDeptId));
        ExcelUtil<MailExcel> util = new ExcelUtil<>(MailExcel.class);
        return util.exportExcel(mailWFDeptList, "本单位信件工单数据");
    }

    /**
     * 本单位不满意信件工单数据导出
     */
    @PostMapping("system/lookup/UnsatisfyMailWF/export")
    @ResponseBody
    public AjaxResult UnsatisfyMailExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId(   ).toString();
        }
        Map<String, Object> param = MapDataUtil.multiTypeParamListToMap(queryConditionVo, sbDeptId);
        if (dataExportDao.mailWFDissatisfyListTotal(param) > 0){
            ExcelUtil<MailExcel> util = new ExcelUtil<>(MailExcel.class);
            List<MailExcel> mailWFDissatisfyList = dataExportDao.mailWFDissatisfyListExport(param);
            return util.exportExcel(mailWFDissatisfyList, "本单位不满意信件工单数据");
        }else {
            return new AjaxResult(AjaxResult.Type.ERROR,"本单位暂无不满意信件工单数据！");
        }
    }

    /**
     * 下级单位信件工单数据导出
     */
    @PostMapping("system/lookup/subDeptMailWF/export")
    @ResponseBody
    public AjaxResult subDeptMWFExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        List<MailExcel> list = dataExportDao.subDeptMailListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sDeptId));
        ExcelUtil<MailExcel> util = new ExcelUtil<>(MailExcel.class);
        return util.exportExcel(list, "下级单位信件工单数据");
    }

    /**
     * 下级单位信件工单数据导出(下拉选择导出)
     */
    @PostMapping("system/lookup/subDeptMailWF/exportSelect")
    @ResponseBody
    public AjaxResult subDeptMWFExportSelect(QueryConditionVo queryConditionVo,int days) {
        SysUser user = getSysUser();
        String sDeptId = null;
        if(user.getDeptId() != null) {
            sDeptId= user.getDeptId().toString();
        }
        String endTime= DateUtils.getDate();
        String startTime=null;
        if(days<0){
            if (days==-1){
                try {
                    Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(endTime);
                    Date date = firstDayOfMonth(parse);
                    startTime= DateUtils.dateTime(date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        }else {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(new Date());
            calendar.add(Calendar.DATE, -days);
            startTime = DateUtils.dateTime(calendar.getTime());
        }

        queryConditionVo.setBeginTime(startTime);
        queryConditionVo.setEndTime(endTime);
        List<MailExcel> list = dataExportDao.subDeptMailListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sDeptId));
        ExcelUtil<MailExcel> util = new ExcelUtil<>(MailExcel.class);
        return util.exportExcel(list, "下级单位信件工单数据");
    }

    //信件操作记录导出
    @PostMapping("system/lookup/MailWFLog/export")
    @ResponseBody
    public AjaxResult MailWFLogExport(QueryConditionVo queryConditionVo) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(queryConditionVo.getEndTime()==null||"".equals(queryConditionVo.getEndTime())){
            Date date = new Date();
            String format = dateFormat.format(date);
            queryConditionVo.setEndTime(format);
        }
        if (queryConditionVo.getBeginTime()==null||"".equals(queryConditionVo.getBeginTime())){
            try {
                Date date = dateFormat.parse(queryConditionVo.getEndTime());
                Calendar calendar = Calendar.getInstance(); //得到日历
                calendar.setTime(date);//把当前时间赋给日历
                calendar.add(calendar.MONTH, -1); //设置为前1月，可根据需求进行修改
                date = calendar.getTime();
                queryConditionVo.setBeginTime(dateFormat.format(date));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        List<MailWorkFormLogExcel> list = commonDao.mailLogListExport(getSysUser().getDeptId().toString(),queryConditionVo);
        ExcelUtil<MailWorkFormLogExcel> util = new ExcelUtil<>(MailWorkFormLogExcel.class);
        return util.exportExcel(list, "信件操作记录数据");
    }

    //电话操作记录导出
    @PostMapping("system/lookup/TelWFLog/export")
    @ResponseBody
    public AjaxResult TelWFLogExport(QueryConditionVo queryConditionVo) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(queryConditionVo.getEndTime()==null||"".equals(queryConditionVo.getEndTime())){
            Date date = new Date();
            String format = dateFormat.format(date);
            queryConditionVo.setEndTime(format);
        }
        if (queryConditionVo.getBeginTime()==null||"".equals(queryConditionVo.getBeginTime())){
            try {
                Date date = dateFormat.parse(queryConditionVo.getEndTime());
                Calendar calendar = Calendar.getInstance(); //得到日历
                calendar.setTime(date);//把当前时间赋给日历
                calendar.add(calendar.MONTH, -2); //设置为前2月，可根据需求进行修改
                date = calendar.getTime();
                queryConditionVo.setBeginTime(dateFormat.format(date));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        List<TelWorkFormLogExcel> list = commonDao.telLogListExport(getSysUser().getDeptId().toString(),queryConditionVo);
        ExcelUtil<TelWorkFormLogExcel> util = new ExcelUtil<>(TelWorkFormLogExcel.class);
        return util.exportExcel(list, "电话操作记录数据");
    }

    /**
     * 下级办理中电话工单
     */
    @PostMapping("system/lookup/telUrge/export")
    @ResponseBody
    public AjaxResult telUrgeExport(QueryConditionVo queryConditionVo) {
        List<String> workFormNo = new ArrayList<>();
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<TelExcel> list = dataExportDao.telUrgeWFListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sbDeptId));
        for (TelExcel telExcel : list) {
            commonController.hidetTel2(user,telExcel);
        }
        ExcelUtil<TelExcel> util = new ExcelUtil<>(TelExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "下级办理中电话工单");
        }
        return new AjaxResult(AjaxResult.Type.ERROR,"导出下级办理中电话工单失败，请重试！");
    }

    /**
     * 待本部门回复电话工单导出
     */
    @PostMapping("system/lookup/telMuReplyWait/export")
    @ResponseBody
    public AjaxResult telMuReplyWaitExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        Long sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId();
        }
        List<MuReplyWaitTelExcel> list = wfSendBackService.muReplyWaitJsonExport(sbDeptId, queryConditionVo);
        ExcelUtil<MuReplyWaitTelExcel> util = new ExcelUtil<>(MuReplyWaitTelExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "待本部门回复电话工单");
        }
        return new AjaxResult(AjaxResult.Type.ERROR,"导出待本部门回复电话工单失败，请重试！");
    }

    /**
     * 待本部门回复电话工单导出
     * gxq
     */
    @PostMapping("system/lookup/telMuReplyWait_gxq/export")
    @ResponseBody
    public AjaxResult telMuReplyWaitExport_gxq(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        Long sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId();
        }
        List<MuReplyWaitTelExcel> list = wfSendBackService.muReplyWaitJsonExport_gxq(sbDeptId, queryConditionVo);
        ExcelUtil<MuReplyWaitTelExcel> util = new ExcelUtil<>(MuReplyWaitTelExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "待本部门回复电话工单");
        }
        return new AjaxResult(AjaxResult.Type.ERROR,"导出待本部门回复电话工单失败，请重试！");
    }

    /**
     * 下级办理中信件工单
     */
    @PostMapping("system/lookup/mailUrge/export")
    @ResponseBody
    public AjaxResult mailUrgeExport(String ids, QueryConditionVo queryConditionVo) {
        List<String> workFormNo = new ArrayList<>();
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<MailExcel> list = dataExportDao.subUrgeMailListExport(MapDataUtil.multiTypeParamListToMap(queryConditionVo,sbDeptId));
        ExcelUtil<MailExcel> util = new ExcelUtil<>(MailExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "下级办理中信件工单");
        } else {
            return new AjaxResult(AjaxResult.Type.ERROR,"导出下级办理中信件工单失败，请重试！");
        }
    }

    /**
     * 待本部门回复信件工单导出
     */
    @PostMapping("system/lookup/mailReplyWait/export")
    @ResponseBody
    public AjaxResult mailReplyWaitExport(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<ReplyWaitMailExcel> list = mwfSendBackService.replyWaitJsonExport(sbDeptId, queryConditionVo);
        ExcelUtil<ReplyWaitMailExcel> util = new ExcelUtil<>(ReplyWaitMailExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "待本部门回复信件工单");
        } else {
            return new AjaxResult(AjaxResult.Type.ERROR,"导出待本部门回复信件工单失败，请重试！");
        }
    }

    /**
     * 待本部门回复信件工单导出
     */
    @PostMapping("system/lookup/mailReplyWait_gxq/export")
    @ResponseBody
    public AjaxResult mailReplyWaitExport_gxq(QueryConditionVo queryConditionVo) {
        SysUser user = getSysUser();
        String sbDeptId = null;
        if(user.getDeptId() != null) {
            sbDeptId= user.getDeptId().toString();
        }
        List<ReplyWaitMailExcel> list = mwfSendBackService.replyWaitJsonExport_gxq(sbDeptId, queryConditionVo);
        ExcelUtil<ReplyWaitMailExcel> util = new ExcelUtil<>(ReplyWaitMailExcel.class);
        if (list.size()>0) {
            return util.exportExcel(list, "待本部门回复信件工单");
        } else {
            return new AjaxResult(AjaxResult.Type.ERROR,"导出待本部门回复信件工单失败，请重试！");
        }
    }

}
